package com.hema.auction.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.tencent.tauth.Tencent;
import com.hema.auction.R;
import com.hema.auction.base.BaseActivity;
import com.hema.auction.http.UrlManager;
import com.hema.auction.http.biz.UpdateManager;
import com.hema.auction.utils.Constant;
import com.hema.auction.utils.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 设置
 * author by john
 */

public class SettingActivity extends BaseActivity {


    @BindView(R.id.tv_version)
    TextView tvVersion;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        tvVersion.setText(Utils.getVersionName(this));
    }

    @OnClick({R.id.ll_novice_guide, R.id.ll_help_center, R.id.ll_service_agreement, R.id.ll_about, R.id.tv_exit, R.id.ll_version})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_send_code:
                break;
            case R.id.tv_exit:
                spManager.setIsLogin(false);
                spManager.clearInfo();
                aCache.clear();
                Tencent.createInstance(Constant.QQ_APP_ID, this).logout(this);
                Bundle extra = new Bundle();
                extra.putInt(Constant.EXTRA_TAB_INDEX, 0);
                intentTo(MainActivity.class, extra);
                finish();
                break;
            case R.id.ll_novice_guide:
                Bundle bundle = new Bundle();
                bundle.putString(Constant.EXTRA_TITLE, getString(R.string.novice_guide));
                bundle.putString(Constant.EXTRA_URL, UrlManager.H5_GUIDE);
                intentTo(H5Activity.class, bundle);
                break;
            case R.id.ll_help_center:
                bundle = new Bundle();
                bundle.putString(Constant.EXTRA_TITLE, getString(R.string.help_center));
                bundle.putString(Constant.EXTRA_URL, UrlManager.H5_HELP);
                intentTo(H5Activity.class, bundle);
                break;
            case R.id.ll_service_agreement:
                bundle = new Bundle();
                bundle.putString(Constant.EXTRA_TITLE, getString(R.string.service_agreement));
                bundle.putString(Constant.EXTRA_URL, UrlManager.H5_AGREEMENT);
                intentTo(H5Activity.class, bundle);
                break;
            case R.id.ll_about:
                bundle = new Bundle();
                bundle.putString(Constant.EXTRA_TITLE, getString(R.string.about));
                bundle.putString(Constant.EXTRA_URL, UrlManager.H5_ABOUT);
                intentTo(H5Activity.class, bundle);
                break;
            case R.id.ll_version:
                UpdateManager.getInstance().checkUpdate(this,true);
                break;
        }
    }

}
